import { createSlice } from '@reduxjs/toolkit'

export const dataSlice = createSlice({
  name: 'data',
  initialState: {
    counter: 100,
    msg: '最冷一天',
    word: '裂缝中的阳光',
  },
  reducers: { // 同步修改
    add(state) {
      state.counter++
    },
    changeMsg(state, { payload }) {
      state.msg = payload
    },
    changeWord(state, { payload }) {
      state.word = payload
    }
  }
})

// 同步修改方法导出
export const { add, changeMsg, changeWord } = dataSlice.actions


export default dataSlice.reducer // 默认暴露
